<template>
  <div class="page-container" :disabled="isAllowOperate">
    <div class="toolbar" style="padding-top:10px;padding-left:15px;">
      <el-row style="text-align: center;margin-top: -18px;">
        <!-- table切换 -->
        <el-tabs type="border-card">
          <el-tab-pane label="基本信息">
            <el-form
              :model="companyConcatForm"
              label-width="180px"
              style="text-align:center;"
              ref="companyConcatForm"
              :rules="dataFormRules"
              :size="size"
              class="form"
            >
              <el-form-item label="ID：" prop="id" v-if="false">
                <el-input v-model="dataForm.id" :disabled="true" auto-complete="off"></el-input>
              </el-form-item>
              <el-divider content-position="center">
                <span style="font-size:16px;font-weight:800">学校基本信息（您填写的信息将展示给卖家请认真填写）</span>
              </el-divider>
              <div style="width:1050px;margin-left:22%">
               <el-row class="searchDialog-input">
                <el-form-item label="学校账号：" prop="storeAccount">
                  <el-input
                    v-model="companyConcatForm.storeAccount"
                    auto-complete="off"
                    :disabled="isAllowOperate||isSys"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校密码：" prop="storePass">
                  <el-input
                    v-model="companyConcatForm.storePass"
                    auto-complete="off"
                    :disabled="isAllowOperate||isSys"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校名称：" prop="storeName">
                  <el-input
                    v-model="companyConcatForm.storeName"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校名称（第二语言）：" prop="storeNames">
                  <el-input
                    v-model="companyConcatForm.storeNames"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校编码：" prop="storeCode">
                  <el-input
                    v-model="companyConcatForm.storeCode"
                    auto-complete="off"
                    :disabled="true"
                  ></el-input>
                </el-form-item>
                <!--<el-form-item label="学校分类" prop="storeType">-->
                  <!---->
                  <!--<el-select-->
                    <!--v-model="companyConcatForm.storeType"-->
                    <!--placeholder="学校分类"-->
                    <!--:disabled="true"-->
                  <!--&gt;-->
                    <!--<el-option-->
                      <!--v-for="item in storeType"-->
                      <!--:key="item.key"-->
                      <!--:label="item.value"-->
                      <!--:value="item.key"-->
                    <!--&gt;</el-option>-->
                  <!--</el-select>-->
                <!--</el-form-item>-->
                <el-form-item label="所属代理商：" prop="merchantName">
                  <el-input v-model="companyConcatForm.merchantName" auto-complete="off" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="学校类型：" prop="storeTypes">
                  <el-select
                    v-model="companyConcatForm.storeTypes"
                    placeholder="学校类型"
                    :disabled="isAllowOperate"
                  >
                    <el-option
                      v-for="item in storeTypes"
                      :key="item.key"
                      :label="item.value"
                      :value="item.key"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="学校所属渠道：" prop="storeChannels">
                  <el-select
                    v-model="companyConcatForm.storeChannels"
                    placeholder="学校所属渠道"
                    :disabled="true"
                  >
                    <el-option
                      v-for="item in storeChannels"
                      :key="item.key"
                      :label="item.value"
                      :value="item.key"
                    ></el-option>
                  </el-select>
                </el-form-item>

                <el-form-item label="类目是否允许自创：" prop="allowHomemade">
                  <el-radio-group  style="float:left" v-model="companyConcatForm.allowHomemade" :disabled="isAllowOperate" class="pt8">
                    <el-radio
                      v-for="item in allowHomemade"
                      :key="item.value"
                      :label="item.value"
                    >{{item.label}}</el-radio>
                  </el-radio-group>
                </el-form-item>

                <el-form-item label="学校简介：" prop="storeIntroduction">
                  <el-input
                    v-model="companyConcatForm.storeIntroduction"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校简介（第二语言）：" prop="storeIntroductions">
                  <el-input
                    v-model="companyConcatForm.storeIntroductions"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校介绍：" prop="storeIntroduce">
                  <el-input
                    type="textarea"
                    v-model="companyConcatForm.storeIntroduce"
                    auto-complete="off"
                    style="width:895px"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校介绍（第二语言）：" prop="storeIntroduces">
                  <el-input
                    type="textarea"
                    v-model="companyConcatForm.storeIntroduces"
                    auto-complete="off"
                    style="width:895px"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-form-item label="学校LOGO：" prop="storeLogo">
                  <el-upload
                    :action="imgUpload"
                    :on-success="handleAvatarSuccess"
                    list-type="picture-card"
                    v-model="companyConcatForm.storeLogo"
                    accept="image/gif, image/jpeg, image/jpg, image/png, image/svg"
                    :on-preview="handlePictureCardPreview"
                    :on-exceed="handleExceed"
                    :limit="1"
                    :file-list="fileList"
                    ref="upload"
                    style="float: left"
                  >
                    <i class="el-icon-plus"></i>
                  </el-upload>
                </el-form-item>
               </el-row> 
                <el-divider content-position="center">
                  <span style="font-size:16px;font-weight:800">联系信息</span>
                </el-divider>
                 <el-row class="searchDialog-input">
                    <el-form-item label="学校联系人：" prop="storeContactor">
                  <el-input
                    v-model="companyConcatForm.storeContactor"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                    @input="characterVer($event)"
                  ></el-input>
                </el-form-item>

                <el-form-item label="联系手机号：" prop="mobile">
                  <el-input
                    v-model="companyConcatForm.mobile"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                    @input="phoneVer($event)"
                  ></el-input>
                </el-form-item>
                <el-form-item label="联系人邮箱：" prop="contactorEmail">
                  <el-input
                    v-model="companyConcatForm.contactorEmail"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-col :span="24">
                  <el-form-item label="经营地址：" prop="addressDetail">
                    <div style="width:880px">
                      <v-distpicker
                        @selected="selected"
                        :province="companyConcatForm.businessProvinceId"
                        :city="companyConcatForm.businessCityId"
                        :area="companyConcatForm.businessRegionId"
                        :disabled="isAllowOperate"
                      ></v-distpicker>
                    </div>
                  </el-form-item>
                </el-col>

                <el-form-item label="详细地址：" prop="addressDetail">
                  <el-input
                    v-model="companyConcatForm.addressDetail"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  >
                    <el-button slot="append" icon="el-icon-location" @click="locationMap"></el-button>
                  </el-input>
                </el-form-item>
                <el-form-item label="地址经纬度：" prop="lnglat">
                  <el-input
                    v-model="companyConcatForm.lnglat"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                <el-form-item label="详细地址（第二语言）：" prop="addressDetails">
                  <el-input
                    v-model="companyConcatForm.addressDetails"
                    auto-complete="off"
                    :disabled="isAllowOperate"
                  ></el-input>
                </el-form-item>
                 </el-row>
              </div>
            </el-form>
            <div class="item clearfix pt_10 mb_0" v-if="isDetail == false">
              <el-checkbox
                id="check"
                type="checkbox"
                style="color: red"
                class="el-checkbox"
                :disabled="isAllowOperate"
              ></el-checkbox>
              <label for="js-mobile-check" class="txt_check_label gray">
                我已阅读并同意
                <span @click="aleryTerm()">
                  <font color="blue">《{{this.terms}}》</font>
                </span>
              </label>

              <el-checkbox
                id="checks"
                type="checkbox"
                style="color: red;margin-left:100px"
                class="el-checkbox1"
                :disabled="isAllowOperate"
                v-model="acchecked"
              ></el-checkbox>
              <label for="js-mobile-check" class="txt_check_label gray">是否接受商家所有商品(勾选为是，默认否)</label>

              <div slot="footer" class="dialog-footer" style="text-align:center">
                <el-button
                  :size="size"
                  type="primary"
                  @click.native="submitForm"
                  :disabled="isAllowOperate"
                >保存</el-button>
              </div>
            </div>
            <el-dialog
              title="提示"
              :visible.sync="mapVisible"
              width="80%"
              :before-close="handleMapClose"
            >
              <AmapHtml :address="companyConcatForm.addressDetail" ref="amapRef"></AmapHtml>
              <span slot="footer" class="dialog-footer">
                <el-button @click="mapVisible = false">取 消</el-button>
                <el-button type="primary" @click="mapVisible = false">确 定</el-button>
              </span>
            </el-dialog>
          </el-tab-pane>
          <!-- 配置管理 -->
          <el-tab-pane label="地址信息">
            <div style="text-align: left;" v-if="isDetail == false">
              <el-button
                :size="size"
                @click="addCertifications"
                type="primary"
                style="text-align:left"
                :disabled="isAllowOperate"
              >添加地址</el-button>
            </div>

            <template>
              <el-table :data="tableDataCertifications" border style="width: 100%">
                <el-table-column prop="addressType" label="地址类型" width="457"></el-table-column>
                <el-table-column prop="defaultaddress" label="是否默认地址"></el-table-column>
                <el-table-column prop="contactor" label="	联系人"></el-table-column>
                <el-table-column prop="contactMobile" label="	联系电话"></el-table-column>
                <el-table-column prop="postcode" label="	邮编"></el-table-column>
                <el-table-column prop="addressDetail" label="	详细地址"></el-table-column>
                <el-table-column prop="remark" label="备注"></el-table-column>
                <el-table-column fixed="right" label="操作" width="150">
                  <template slot-scope="scope">
                    <el-button
                      type="primary"
                      size="small"
                      @click="editAddressInfo(scope.row)"
                      :disabled="isAllowOperate"
                    >编辑</el-button>
                    <el-button
                      type="danger"
                      size="small"
                      @click="deleteAddressInfo(scope.row.id)"
                      :disabled="isAllowOperate"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </template>

            <!-- 添加地址 -->
            <el-dialog
              title="添加地址"
              width="55%"
              :visible.sync="certificationModal"
              :close-on-click-modal="false"
              @closed="handleClose"
            >
              <el-form
                :model="certificationForm"
                label-width="150px"
                :rules="certificationFormRules"
                ref="certificationForm"
                :size="size"
                label-position="right"
                inline
              >
                <el-row class="searchDialog-input">
                  <el-form-item label="地址类型：" prop="addressType">
                    <el-select
                      v-model="certificationForm.addressType"
                      style="width:350px"
                      placeholder="地址类型"
                      :disabled="addressDis"
                      @change="changeType($event)"
                    >
                      <el-option
                        v-for="item in addressTypeList"
                        :key="item.key"
                        :label="item.value"
                        :value="item.key"
                      ></el-option>
                    </el-select>
                  </el-form-item>

                  <el-form-item label="联系人：" prop="contactor">
                    <el-input
                      v-model="certificationForm.contactor"
                      auto-complete="off"
                      style="width:350px"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="联系手机：" prop="contactMobile">
                    <el-input
                      v-model="certificationForm.contactMobile"
                      auto-complete="off"
                      style="width:350px"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="邮编：" prop="postcode">
                    <el-input
                      v-model="certificationForm.postcode"
                      auto-complete="off"
                      style="width:350px"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                  <el-col :span="24">
                    <el-form-item label="省市区：" prop="addressDetail">
                      <div style="width:880px">
                        <v-distpicker
                          @selected="addressSelected"
                          :province="certificationForm.province"
                          :city="certificationForm.city"
                          :area="certificationForm.region"
                        ></v-distpicker>
                      </div>
                    </el-form-item>
                  </el-col>

                  <el-form-item label="详细地址：" prop="addressDetail">
                    <el-input
                      v-model="certificationForm.addressDetail"
                      auto-complete="off"
                      style="width:350px"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                  <el-form-item label="详细地址(第二语言)：" prop="addressDetails" label-width="150px">
                    <el-input
                      v-model="certificationForm.addressDetails"
                      auto-complete="off"
                      style="width:350px"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>

                  <el-form-item label="备注：" prop="remark">
                    <el-input
                      v-model="certificationForm.remark"
                      auto-complete="off"
                      style="width:350px"
                      type="textarea"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                  <el-form-item
                    :label="defaultaddressName"
                    prop="defaultaddress"
                    label-width="150px"
                  >
                    <el-checkbox v-model="checked" auto-complete="off" @change="isConfirm"></el-checkbox>
                  </el-form-item>
                </el-row>
              </el-form>
              <div slot="footer" class="dialog-footer" style="text-align:center">
                <el-button :size="size" @click="saveCertification" type="primary">确认</el-button>
                <el-button :size="size" @click="clearCertificationModal" type="primary">取消</el-button>
              </div>
            </el-dialog>
          </el-tab-pane>

          <el-tab-pane label="供应商学校映射">
            <div style="text-align: left;" v-if="isDetail == false">
              <el-button
                :size="size"
                @click="addbrandForm"
                type="primary"
                style="text-align:left"
                :disabled="isAllowOperate"
              >映射外部学校</el-button>
            </div>

            <template>
              <el-table border style="width: 100%" :data="supplieridData">
                <el-table-column prop="supplierid" label="供应商名称"></el-table-column>
                <el-table-column prop="storesupplierid" label="对应供应商学校ID"></el-table-column>
                <el-table-column prop="status" label="状态"></el-table-column>

                <el-table-column fixed="right" label="操作">
                  <template slot-scope="scope">
                    <el-button
                      type="text"
                      size="small"
                      :disabled="isAllowOperate"
                      @click="updateSupplierInfo(scope.row.id)"
                    >编辑</el-button>
                    <el-button
                      type="text"
                      size="small"
                      :disabled="isAllowOperate"
                      @click="updateStatus(scope.row)"
                    >启/停用</el-button>
                    <el-button
                      @click="delSupplierInfo(scope.row.id)"
                      type="text"
                      size="small"
                      :disabled="isAllowOperate"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </template>

            <!--  -->
            <el-dialog
              title="添加供应商"
              width="30%"
              :visible.sync="brandModal"
              :close-on-click-modal="false"
            >
              <el-form
                :model="brandForm"
                label-width="150px"
                ref="brandForm"
                :rules="brandFormRules"
                :size="size"
                label-position="right"
                inline
              >
                <el-row class="searchDialog-input">
                  <el-form-item label="供应商：" prop="supplierid">
                    <el-select
                      v-model="brandForm.supplierid"
                      placeholder="供应商"
                      :disabled="suType"
                      style="width:350px"
                    >
                      <el-option
                        v-for="item in supplierid"
                        :key="item.key"
                        :label="item.value"
                        :value="item.key"
                      ></el-option>
                    </el-select>
                  </el-form-item>

                  <el-form-item label="对应供应商学校ID：" prop="storesupplierid">
                    <el-input
                      v-model="brandForm.storesupplierid"
                      auto-complete="off"
                      style="width:350px"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>

                  <el-form-item label="备注：" prop="remark">
                    <el-input
                      v-model="brandForm.remark"
                      auto-complete="off"
                      style="width:350px"
                      type="textarea"
                      placeholder="请输入"
                    ></el-input>
                  </el-form-item>
                </el-row>
              </el-form>
              <div slot="footer" class="dialog-footer" style="text-align:center">
                <el-button :size="size" @click="saveSupplierInfo" type="primary">确认</el-button>
                <el-button :size="size" @click="clearSupplier">{{$t('action.cancel')}}</el-button>
              </div>
            </el-dialog>
          </el-tab-pane>
          <!-- 学校入驻条款 -->

          <el-dialog
            title="学校入驻条款"
            width="40%"
            :center="true"
            :visible.sync="termModel"
            :close-on-click-modal="false"
          >
            <el-form label-width="100px" :size="size" label-position="right" inline>
              <!-- <div class="contentStyle">{{this.content}}</div> -->

              <div class="contentStyle" v-html="content"></div>

              <!-- <el-row>
                <el-input v-model="content" auto-complete="off" style="width:500px;max-height:600px;overflow-y:scroll;height:400px" type="textarea" ></el-input>
              </el-row>-->
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align:center">
              <el-button :size="size" @click="clearTermModel">{{$t('action.cancel')}}</el-button>
            </div>
          </el-dialog>

          <!-- <el-tab-pane label="渠道">渠道</el-tab-pane> -->
        </el-tabs>
      </el-row>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import Cookies from "js-cookie";
import ThemePicker from "@/components/ThemePicker";
import LangSelector from "@/components/LangSelector";
import Vue from "vue";
import VDistpicker from "v-distpicker";
import AmapHtml from "./AmapHtml";

export default {
  name: "StorreInfoEdit",
  components: {
    ThemePicker,
    LangSelector,
    VDistpicker,
    AmapHtml
  },
  data() {
    return {
      addressDis: false,
      allowHomemade: [{ label: "允许", value: 0 }, { label: "不允许", value:1 }],
      acchecked: false,
      mapVisible: false, //地图弹窗
      radio: "0",
      bill_photo_list: [],
      suType: false,
      defaultaddressName: "设置默认发货地址",
      terms: "",
      content: "",
      isSys: true,
      isAllowOperate: false,
      imgUpload: "http://139.217.220.198:8094/api/upload",
      storeLogo: "",
      //渠道选择
      storeChannels: [
        { key: "0", value: "BBC" },
        { key: "1", value: "天猫" },
        { key: "4", value: "京东" }
      ],
      addressTypeList: [
        { key: 0, value: "发货地址" },
        { key: 1, value: "退货地址" }
      ],
      //学校选择
      storeType: [{ key: "1", value: "线上学校" }],
      storeTypes: [{ key: 0, value: "直营" }],
      supplierid: [{ key: 0, value: "insight" }],
      cid: this.$route.params.id,
      storeid: this.$route.params.id,
      merchantid: this.$route.params.merchantId,
      isDetail: this.$route.params.isDetail,
      imageUrl: "",

      size: "small",
      fileList:[],
      response: {},
      tableDataCertifications: [{}],
      supplieridData: [{}],
      file: {},
      imgs: "",
      imgs1: "",
      imgs2: "",
      index: 1,
      businessProvinceId: "",
      businessCityId: "",
      businessRegionId: "",
      contactAddressProvinceId: "",
      contactAddressCityId: "",
      contactAddressRegionId: "",
      dataForm: {
        name: "",
        storeLogo: "",
        paperwork_photo: "",
        manager_photo: ""
      },
      termForm: {},
      dialogImageUrl: "",
      loading: false,
      dialogVisibleImage: false,
      certificationModal: false,
      brandModal: false,
      termModel: false,
      addInp: false,
      mask: false,
      brand1: false,
      brand2: false,
      loginForm: {
        account: "",
        password: "",
        captcha: "",
        src: ""
      },
      dataFormRules: {
        storeName: [
          { required: true, message: "请输入学校名称", trigger: "blur" }
        ],
        storeNames: [
          {
            required: true,
            message: "请输入学校名称(第二语言)",
            trigger: "blur"
          }
        ],
        storeCode: [
          { required: true, message: "请输入学校编码", trigger: "blur" }
        ],
        storeType: [
          { required: true, message: "请选择学校分类", trigger: "blur" }
        ],
        storeChannels: [
          { required: true, message: "请选择学校渠道", trigger: "blur" }
        ],
        allowHomemade: [
          { required: true, message: "请选择是否允许", trigger: "blur" }
        ],
        storeIntroduction: [
          { required: true, message: "请输入学校简介", trigger: "blur" }
        ],
        storeIntroductions: [
          {
            required: true,
            message: "请输入学校简介(第二语言)",
            trigger: "blur"
          }
        ],
        storeIntroduce: [
          { required: true, message: "请输入学校介绍", trigger: "blur" }
        ],
        storeIntroduces: [
          {
            required: true,
            message: "请输入学校介绍(第二语言)",
            trigger: "blur"
          }
        ],
        storeContactor: [
          { required: true, message: "请输入学校联系人", trigger: "blur" }
        ],

        contactorEmail: [
          { required: true, message: "请输入联系人邮箱", trigger: "blur" }
        ],
        mobile: [{ required: true, message: "请输入手机号", trigger: "blur" }],
        addressDetail: [
          { required: true, message: "请输入详细地址", trigger: "blur" }
        ],
        addressDetails: [
          {
            required: true,
            message: "请输入详细地址（第二语言）",
            trigger: "blur"
          }
        ],
        businessProvinceId: [
          { required: true, message: "请选择经营地址省", trigger: "blur" }
        ],
        businessCityId: [
          { required: true, message: "请选择经营地址市", trigger: "blur" }
        ],
        businessRegionId: [
          { required: true, message: "请选经营地址区", trigger: "blur" }
        ]
      },

      //地址验证
      certificationFormRules: {
        addressType: [
          { required: true, message: "请选择地址类型", trigger: "blur" }
        ],
        contactor: [
          {
            required: true,
            message: "请输入联系人",
            trigger: "blur"
          }
        ],
        contactMobile: [
          { required: true, message: "请输入联系电话", trigger: "blur" }
        ],
        postcode: [{ required: true, message: "请输入邮编", trigger: "blur" }],
        province: [{ required: true, message: "请选择省", trigger: "change" }],
        addressDetail: [
          { required: true, message: "请输入详细地址", trigger: "blur" }
        ],

        city: [{ required: true, message: "请选择市", trigger: "change" }],
        region: [{ required: true, message: "请选择区", trigger: "change" }]
      },

      //供应商验证
      brandFormRules: {
        supplierid: [
          {
            required: true,
            message: "选择供应商名称",
            trigger: "blur"
          }
        ],
        storesupplierid: [
          { required: true, message: "请输入对应供应商id", trigger: "blur" }
        ],

        remark: [{ required: true, message: "请输入备注", trigger: "blur" }]
      },
      certificationForm: {},
      brandForm: {},
      companyConcatForm: {
        businessProvinceId: "",
        businessCityId: "",
        businessRegionId: "",
        allowHomemade:""
      },
      fieldRules: {
        account: [{ required: true, message: "请输入账号", trigger: "blur" }],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }]
        // ,
        // captcha: [
        //   { required: true, message: '请输入验证码', trigger: 'blur' }
        // ]
      },
      checked: false,
      customer_type_options: [],
      paperwork_type_options: [],
      trade_type_options: []
    };
  },
  methods: {
    //文件上传数量限制
    handleExceed: function () {
      this.$alert('最多上传一个', '警告', {
        confirmButtonText: '确定'
      });
    },
    //取消新增地址弹框
    clearCertificationModal() {
      this.certificationModal = false;
      if (this.$refs["certificationForm"]) {
        this.$refs["certificationForm"].clearValidate();
      }
    },
    //输入框验证
    characterVer(e) {
      //汉字验证
      const correct = e.replace(/[^\u4E00-\u9FA5]/g, ""); // 清除除了中文以外的输入的字符

      this.companyConcatForm.storeContactor = correct;
    },
    phoneVer(e) {
      //手机号验证

      let filtered = e.replace(/^0|[^\d]/g, "");
      if (this.companyConcatForm.mobile != filtered) {
        this.$message({ message: "请输入正确的手机号", type: "error" });
        this.companyConcatForm.mobile = "";
      }
    },

    adddriverChid: function(data) {
      console.log("ssssssssss");
    },

    aleryTerm: function(data) {
      let this_ = this;
      this_.termModel = true;
    },
    clearTermModel: function(data) {
      let this_ = this;
      this_.termModel = false;
    },

    //入驻条款查询
    getTermsInfo() {
      let this_ = this;
      let param = {};
      param.entryType = 2;
      this.utils.request.getTermsInfo(param, function(res) {
        if (res.data != null) {
          this_.terms = res.data.title;
          console.log(res.data);
          this_.content = res.data.content;
        }
      });
    },

    //页面回显基本信息
    getStoreDetail() {
      let this_ = this;
      var query = {};
      if (this_.isDetail == 1) {
        query.isDetail = this_.isDetail;
        this_.isAllowOperate = true;
      }
      if (this.cid != null && this.cid != 0) {
        query.id = this_.cid;

        this.utils.request.getStoreInfo(query, function(res) {
          console.log(query);
          if (res.data != null) {
            if(res.data.storeLogo!=""){
              this_.fileList=[]
              let obj={}
              obj.name="店铺图片"
              obj.url=res.data.storeLogo
              this_.fileList.push(obj)
            }
            $.each(res.data, function(index, value) {
              if (value != null) {
                this_.companyConcatForm = res.data;

                this_.companyConcatForm.businessProvinceId =
                  res.data.businessProvinceId;
                this_.companyConcatForm.businessCityId =
                  res.data.businessCityId;
                this_.companyConcatForm.businessRegionId =
                  res.data.businessRegionId;
                this_.companyConcatForm.allowHomemade = res.data.allowHomemade;
                //  this_.bill_photo_list = this_.companyConcatForm.storeLogo.split(",");

                if (res.data.isAccept == 0) {
                  this_.acchecked = false;
                } else if (res.data.isAccept == 1) {
                  this_.acchecked = true;
                }
              }
            });
          }
        });
      }
    },

    //地址列表查询
    getAddressList() {
      let this_ = this;
      var query = {};

      if (this.cid != null && this.cid != 0) {
        query.storeId = this_.storeid;
        this.utils.request.getAddressList(query, function(res) {
          if (res.data != null) {
            $.each(res.data, function(index, val) {
              if (val.addressType == 0) {
                val.addressType = "发货地址";
              } else if (val.addressType == 1) {
                val.addressType = "退货地址";
              }
              if (val.defaultaddress == 0) {
                val.defaultaddress = "是";
              } else if (val.defaultaddress == 1) {
                val.defaultaddress = "否";
              }
            });
            this_.tableDataCertifications = res.data;
          }
        });
      }
    },

    //供应商列表查询
    getSupplierList() {
      let this_ = this;
      var query = {};

      if (this.cid != null && this.cid != 0) {
        query.storeId = this_.storeid;
        this.utils.request.getSupplierList(query, function(res) {
          if (res.data != null) {
            $.each(res.data, function(index, val) {
              if (val.supplierid == 0) {
                val.supplierid = "insight";
              }
              if (val.status == 0) {
                val.status = "启用";
              } else if (val.status == 1) {
                val.status = "禁用";
              }
            });
            this_.supplieridData = res.data;
          }
        });
      }
    },

    //修改学校地址

    editAddressInfo(data) {
      if (this.$refs["certificationForm"]) {
        this.$refs["certificationForm"].clearValidate();
      }
      this.certificationModal = true;
      this.addressDis = true;
      console.log(data, "++++++");
      if (data.addressType === "发货地址") {
        this.defaultaddressName = "设置默认发货地址";
      } else if (data.addressType === "退货地址") {
        this.defaultaddressName = "设置默认退货地址";
      }

      //复选框是否选中
      if (data.defaultaddress === "是") {
        this.checked = true;
      } else if (data.defaultaddress === "否") {
        this.checked = false;
      }

      this.certificationForm = data;
      this.certificationForm.addressType = data.addressType;
    },

    //修改供应商
    updateSupplierInfo(data) {
      if (this.$refs["brandForm"]) {
        this.$refs["brandForm"].clearValidate();
      }

      let this_ = this;
      this.brandModal = true;
      let params = {};
      params.id = data;
      this.utils.request.getSupplierInfo(params, function(res) {
        if (res.data != null) {
          this_.brandForm = res.data;
        }
      });
    },

    //启用停用按钮{
    updateStatus(data) {
      console.log(data);

      let this_ = this;
      let params = {};
      params.id = data.id;

      if (data.status === "禁用") {
        params.status = 0;
      } else if (data.status === "启用") {
        params.status = 1;
      }
      this.utils.request.upSupplierStatus(params, function(data) {
        console.log(params, "+++++++");
        if (data.code == "0000") {
          this_.$message({ message: "操作成功", type: "success" });
          this_.getSupplierList();
        }
      });
    },

    //删除学校地址
    deleteAddressInfo(data) {
      this.$confirm("确认删除吗？", "提示", {}).then(() => {
        let this_ = this;
        var query = {};
        query.id = data;
        // params.document_license=this.ImageUrl;
        this.utils.request.deleteAddressInfo(query, this.deleteAddressInfoBack);
      });
    },

    //删除地址回调
    deleteAddressInfoBack: function(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
        this.getAddressList();
      } else {
        this.$message({ message: "操作失败, ", type: "error" });
      }
    },

    //删除供应商
    delSupplierInfo(data) {
      this.$confirm("确认删除吗？", "提示", {}).then(() => {
        let this_ = this;
        var query = {};
        query.id = data;
        // params.document_license=this.ImageUrl;
        this.utils.request.delSupplierInfo(query, this.delSupplierInfoBack);
      });
    },

    //删除供应商回调
    delSupplierInfoBack: function(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
        this.getSupplierList();
      } else {
        this.$message({ message: "操作失败, ", type: "error" });
      }
    },

    //取消按钮
    clearSupplier: function(data) {
      let this_ = this;
      this_.brandModal = false;
      this_.brandForm = {};
    },

    // 保存学校
    submitForm: function() {
      if ($(".el-checkbox input[type='checkbox']").is(":checked") == false) {
        this.$message({
          message: "请阅读并勾选《开通业务协议》 ",
          type: "error"
        });
        return;
      }
      this.$refs.companyConcatForm.validate(valid => {
        if (valid) {
          this.$confirm("确认提交吗？", "提示", {}).then(() => {
            let this_ = this;
            this.editLoading = true;
            if(this_.fileList.length>0){
              this_.companyConcatForm.storeLogo=this_.fileList[0].url
            }
            let params = Object.assign({}, this.companyConcatForm);
            params.id = this_.cid;
            params.merchantid = this_.merchantid;
            params.businessProvinceId = this_.businessProvinceId;
            params.businessCityId = this_.businessCityId;
            params.businessRegionId = this_.businessRegionId;
            if (this_.acchecked == true) {
              params.isAccept = 1;
            } else {
              params.isAccept = 0;
            }
            // params.document_license=this.ImageUrl;
            this.utils.request.editStoreInfo(params, this.editInfoBack);
          });
        }
      });
    },
    editInfoBack: function(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
        this.getStoreDetail();
      } else {
        this.$message({ message: "操作失败, ", type: "error" });
      }
    },
    changeData() {
      console.log(this.dataForm.business_start);
    },
    isConfirm(data) {
      console.log("========" + data);
      if (this.defaultaddressName.length == 0) {
        this.$message({ message: "请先选择地址类型, ", type: "error" });
      }
    },
    //添加地址
    addCertifications() {
      if (this.$refs["certificationForm"]) {
        this.$refs["certificationForm"].clearValidate();
      }
      this.certificationModal = true;
      this.certificationForm = {};
      this.addressDis = false;
      this.checked = false;
    },
    //保存地址方法
    saveCertification() {
      this.$refs.certificationForm.validate(valid => {
        if (valid) {
          let this_ = this;
          this.editLoading = true;
          let params = Object.assign({}, this.certificationForm);
          if (params.addressType === "发货地址") {
            params.addressType = 0;
          } else if (params.addressType === "退货地址") {
            params.addressType = 1;
          }
          params.province = this_.province;
          params.city = this_.city;
          params.region = this_.region;
          params.storeId = this_.storeid;
          if (this_.checked == true) {
            params.defaultaddress = 0;
          } else if (this_.checked == false) {
            params.defaultaddress = 1;
          }
          this.utils.request.saveAddressInfo(params, this.editAddressBack);
        }
      });
    },
    //修改地址回调
    editAddressBack: function(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
        this.getAddressList();
        this.certificationModal = false;
      } else {
        this.$message({ message: "操作失败, ", type: "error" });
      }
    },
    handleClose() {
      this.getAddressList();
    },
    //供应商
    addbrandForm() {
      if (this.$refs["brandForm"]) {
        this.$refs["brandForm"].clearValidate();
      }
      this.brandModal = true;
      this.brandForm = {
        supplierid: "",
        storesupplierid: "",
        status: "0",
        remark: ""
      };
    },

    //保存供应商
    saveSupplierInfo() {
      this.$refs.brandForm.validate(valid => {
        if (valid) {
          this.$confirm("确认提交吗？", "提示", {}).then(() => {
            let this_ = this;
            this.editLoading = true;
            let params = Object.assign({}, this.brandForm);
            params.storeId = this_.storeid;
            this.utils.request.saveSupplierInfo(
              params,
              this.editSupplierInfoBack
            );
          });
        }
      });
    },

    //编辑供应商回调
    editSupplierInfoBack: function(data) {
      if (data.code == "0000") {
        this.$message({ message: "操作成功", type: "success" });
        this.getSupplierList();
        this.brandModal = false;
      } else {
        this.$message({ message: "操作失败, ", type: "error" });
      }
    },
    //添加
    addBrand: function(data) {
      let this_ = this;
    },
    //移除
    removeCouponSet: function(index) {
      let this_ = this;
      this.index.remove();
      // var temp = [];
      // $.each(this_.couponSetData, function(key, val) {
      //   if (key == index) {
      //   } else {
      //     temp.push(val);
      //   }
      // });
    },

    selected(data) {
      this.mask = false;
      this.addInp = false;

      this.businessProvinceId = data.province.value;

      this.businessCityId = data.city.value;

      this.businessRegionId = data.area.value;
    },
    addressSelected(data) {
      this.mask = false;
      this.addInp = false;

      this.province = data.province.value;

      this.city = data.city.value;

      this.region = data.area.value;
    },
    toAddress() {
      this.mask = true;
      this.addInp = true;
    },
    //修改地址类型
    changeType(data) {
      if (data == 0 || data === "设置默认发货地址") {
        this.defaultaddressName = "设置默认发货地址";
      } else if (data == 1 || data === "设置默认退货地址") {
        this.defaultaddressName = "设置默认退货地址";
      }
    },

    //处理图片卡预览
    handlePictureCardPreview(file) {
     window.open(file.url)
    },
    //上传成功回调
    handleAvatarSuccess(res, file) {
       let obj={}
       obj.name=file.name
       obj.url=res.data.imgUrl
       this.fileList.push(obj)
    },
    locationMap() {
      let address = this.companyConcatForm.addressDetail;
      if (address != "" && address != null) {
        this.mapVisible = true;
        setTimeout(() => {
          this.companyConcatForm.lnglat =
            this.$refs["amapRef"].lnglat.lng +
            "," +
            this.$refs["amapRef"].lnglat.lat;
        }, 1000);
      }
    },
    //关闭地图弹窗
    handleMapClose() {
      this.mapVisible = false;
    }
  },
  mounted() {
    // this.initSysConfig();
    this.getStoreDetail();
    this.getAddressList();
    this.getSupplierList();
    this.getTermsInfo();
  },
  computed: {
    ...mapState({
      themeColor: state => state.app.themeColor
    })
  }
};
</script>

<style lang="scss" scoped>
.login-container {
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-border-radius: 5px;
  background-clip: padding-box;
  margin: 100px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
  .title {
    margin: 0px auto 30px auto;
    text-align: center;
    color: #505458;
  }
  .remember {
    margin: 0px 0px 35px 0px;
  }
}
</style>
<style  scoped lang='scss'>
/deep/ .form .el-input__inner {
  width: 880px !important;
}
.form .el-textarea__inner {
  width: 880px !important;
}
.form .item {
  padding: -5px 0;
}
/deep/.distpicker-address-wrapper select {
  padding: 0.5rem 0.75rem;
  height: 34px;
  font-size: 0.8rem;
  width: 290px;
}
.form .el-form-item--small.el-form-item {
  margin-bottom: 13px;
}
.contentStyle {
  position: relative;
  padding: 15px 0px 15px 0px;
  max-height: 600px;
  overflow-y: scroll;
  border-top: 1px solid #e5e5e5;
  border-bottom: 1px solid #e5e5e5;
}
.pt8{
  padding-top: 8px;
}
</style>
